//
//  TagButton.m
//  XiangMuB
//
//  Created by lanou3g on 16/8/16.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "TagButton.h"

#import "UIView+FrameView.h"

@implementation TagButton

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setImage:[UIImage imageNamed:@"chose_tag_close_icon"] forState:UIControlStateNormal];
        self.backgroundColor = [UIColor darkGrayColor];
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        
    }
    return self;
    
}



- (void)setTitle:(NSString *)title forState:(UIControlState)state{
    
    [super setTitle:title forState:state];
    [super sizeToFit];
    
    
    self.width += 3*5;
    self.height = 25;
    
}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.titleLabel.x = 5;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + 5;
    
//    CGSize size = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}];
//    
//    self.width = size.width + 30;
    
    
    
    
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
